﻿using System;
using System.Linq;
using GLWrap.MathExt;
using ReAnimation.Domain.Policies.Interfaces;
using ReAnimation.Domain.Policies.Interfaces.ErrorEnums;
using ReAnimation.Helpers.Common;
using Sharp3D.Math.Core;
using OpenBabel;
using System.Text;

namespace ReAnimation.Domain.Policies
{
    public class ZMatrixPolicy: IZMatrixPolicy
    {
        private IVisualizationPolicy _visualizationPolicy;

        public ZMatrixPolicy(IVisualizationPolicy visualizationPolicy)
        {
            _visualizationPolicy = visualizationPolicy;
        }

        public ValidationResult<IncorrectZMatrixErrors> CheckZMatrix(ZMatrix zMatrix)
        {
            if (zMatrix.ZMatrixLines.Any(zMatrixLine => zMatrixLine.AtomDescription == null))
            {
                return ValidationResult<IncorrectZMatrixErrors>.FailValidation(IncorrectZMatrixErrors.NullAtomType);
            }

            if (zMatrix.ZMatrixLines.Count < 3)
            {
                return ValidationResult<IncorrectZMatrixErrors>.FailValidation(IncorrectZMatrixErrors.SmallNumberOfZMatrixLines);
            }

            return ValidationResult<IncorrectZMatrixErrors>.SuccessValidation();
        }
    }
}